<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
<head>
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
</head>
<body>

<script>
function validateGPA(inputText) {
  var numbers = /^[0-9.]+$/;

  if(!(inputText.value.match(numbers))) {
    alert('GPA Error: Only Postivie Decimal Numbers Allowed');
    inputText.value = "0.0";
    return false;
  }
  else if (inputText.value > 6.0) {
    alert('GPA Error: Max GPA allowed is 6.0');
    inputText.value = "0.0";
    return false;    
  }
  else if (0.0 > inputText.value) {
    alert('GPA Error: Minimum GPA allowed is 0.0');
    inputText.value = "0.0";
    return false;    
  }
  else {
    return true;
  }
}

function validateSAT(inputText) {
  var numbers = /^[0-9]+$/;

  if(!(inputText.value.match(numbers))) {
    alert('SAT Error: Only Positive Numbers Allowed');
    inputText.value = "0";
    return false;
  }
  else if (inputText.value > 800) {
    alert('SAT Error: Max Score allowed is 800');
    inputText.value = "0";
    return false;    
  }
  else {
    return true;
  }
  
}

function validateACT(inputText) {
  var numbers = /^[0-9]+$/;

  if(!(inputText.value.match(numbers))) {
    alert('ACT Error: Only Positive Numbers Allowed');
    inputText.value = "0";
    return false;
  }
  else if (inputText.value > 36) {
    alert('ACT Error: Max Score allowed is 36');
    inputText.value = "0";
    return false;    
  }
  else {
    return true;
  }
	  
}

</script>


<div class="header">
<br></br>
<h2>#{userBean.accountInfo.firstname}'s Education Info Page</h2>
<br></br>
</div>

<div class="menu">
<h:form>
<br></br>
<br></br>
<center>
   <h:commandButton value="  Return to Info   " 
                    action="#{navigationBean.modifyInfo}"/>
<br></br>
<br></br>
    <h:commandButton value="  Return to Main  "  
                     action="#{navigationBean.returnToMain}"/>

</center>

</h:form>
</div>

<div id="content" style="margin-left:155px; margin-top: 50px;">
   <br></br>
   <br></br>
   <br></br>
   <center>
      <h:form>
      <h:outputLabel value="Modify #{userBean.accountInfo.firstname}'s Education Info " />

   <br></br>

      <c:when test="${not empty GPA_error}"> 
         <center>
            <font color="red">#{modifyEducation.GPA_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty mathSAT_error}"> 
         <center>
            <font color="red">#{modifyEducation.mathSAT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty creadSAT_error}"> 
         <center>
            <font color="red">#{modifyEducation.creadSAT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty writeSAT_error}"> 
         <center>
            <font color="red">#{modifyEducation.writeSAT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty mathACT_error}"> 
         <center>
            <font color="red">#{modifyEducation.mathACT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty readACT_error}"> 
         <center>
            <font color="red">#{modifyEducation.readACT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty englishACT_error}"> 
         <center>
            <font color="red">#{modifyEducation.englishACT_error}</font>
         </center>
      </c:when>

      <c:when test="${not empty scienceACT_error}"> 
         <center>
            <font color="red">#{modifyEducation.scienceACT_error}</font>
         </center>
      </c:when>

   <br></br>

      <h:panelGrid columns="3" border="2">
      <h:outputText value="GPA :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.GPA} "></h:outputText>
      <h:inputText id="GPA" 
                   value="#{modifyEducation.entered_GPA}"
                   onchange="return validateGPA(this);"></h:inputText>>

      <h:outputText value="SAT Math Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.mathSAT} "></h:outputText>
      <h:inputText id="mathsat"
                   value="#{modifyEducation.entered_mathSAT}"
                   onchange="return validateSAT(this);"></h:inputText>>

      <h:outputText value="SAT Critical Reading Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.creadSAT} "></h:outputText>
      <h:inputText id="creadsat"
                   value="#{modifyEducation.entered_creadSAT}"
                   onchange="return validateSAT(this);"></h:inputText>>

      <h:outputText value="SAT Writing Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.writeSAT} "></h:outputText>
      <h:inputText id="writesat"
                   value="#{modifyEducation.entered_writeSAT}"
                   onchange="return validateSAT(this);"></h:inputText>>

      <h:outputText value="ACT Math Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.mathACT} "></h:outputText>
      <h:inputText id="mathact"
                   value="#{modifyEducation.entered_mathACT}"
                   onchange="return validateACT(this);"></h:inputText>>

      <h:outputText value="ACT Read Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.readACT} "></h:outputText>
      <h:inputText id="readact"
                   value="#{modifyEducation.entered_readACT}"
                   onchange="return validateACT(this);"></h:inputText>>

      <h:outputText value="ACT English Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.englishACT} "></h:outputText>
      <h:inputText id="englishact"
                   value="#{modifyEducation.entered_englishACT}"
                   onchange="return validateACT(this);"></h:inputText>>

      <h:outputText value="ACT Science Score :"></h:outputText>
      <h:outputText value=" #{userBean.educationInfo.scienceACT} "></h:outputText>
      <h:inputText id="scienceact"
                   value="#{modifyEducation.entered_scienceACT}"
                   onchange="return validateACT(this);"></h:inputText>>

      </h:panelGrid>
   <br></br>
      <h:commandButton value="  Submit  " 
                      action="#{modifyEducation.saveEducationInfo}"/>

    </h:form>
</center>

<br></br><br></br><br></br><br></br>
</div>

<div class="footer">
<br></br>
<h3> College Decision Helper </h3>
<br></br>
</div>

</body>
</html>